1. Field of the Invention
The present invention relates to a method for processing transactions. More particularly, the present invention is related to a method and system for processing a combined transaction including multiple select queries.
2. Description of Related Art
Generally, transaction processing in a database is designed so that the database is kept consistent. In transaction processing, all of multiple interdependent operations are always either completed or cancelled. For that purpose, the lock, rollback, and deadlock avoidance mechanisms exist.
A lock refers to controlling access to or update of specific data. In particular, a lock refers to, in writing to a database, temporarily restricting access to the database, that is, temporarily restricting data read or write from or to the database to maintain data integrity. More specifically, exclusive control is performed which, when one process is accessing data X, prevents another process from accessing X. Where one process is represented by two or more SQL statements, a transaction is used.
A transaction is a function that can collectively commit (determine) or roll back (cancel) a series of processes (processing of multiple select and update queries by using SQL statements). By using a transaction, when one SQL statement fails, all the other SQL statements in the same process can be cancelled. A rollback refers to a process of, when a transaction fails before committed, restoring the database to its state before starting the transaction. A deadlock refers to a phenomenon in which two or more transactions being processed are prevented from proceeding when attempting to concurrently access the same portion of the database. For example, assuming that a transaction A is accessing data X and a transaction B is accessing data Y, a deadlock occurs when A attempts to access Y or when B attempts to access X. In this case, any transactions cannot proceed. To avoid such a deadlock, both transactions are cancelled and rolled back. The transactions are performed again in a changed order to prevent recurrence of a deadlock.
Japanese Unexamined Patent Application Publication No. 1993-0108452 discloses a technology, which in controlling concurrent execution of multiple transactions using multiple lock controls, accumulates lock requests made continuously, and when a request other than a lock request is made, sends the accumulated lock requests collectively to the database server and processes the locks before processing this request so as to reduce the frequency of sending a lock request.
Japanese Unexamined Patent Application Publication No. 2009-0271665 discloses a method of, rather than processing inputted multiple transactions separately, retrieving a data item to be processed by the multiple transactions only once, updating the multiple transactions sequentially with respect to the retrieved data item in the main memory, and writing only the update results to the database.
The above-mentioned conventional methods do not employ a method of combining multiple transactions into one and requesting the database to process the combined transaction. The reasons are because it is difficult to combine SQL statements present in multiple transactions (select queries), and even if SQL statements can be combined, a deadlock can occur if there is a single transaction for updating the referred data when a combined select query is being sent to the database.